class MainDoubleClick {
	Main: egret.DisplayObject;

	constructor(Main: egret.DisplayObject) {
		this.Main = Main;
		Main.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchBeginMain, this);
	}

	doubleClick: egret.DisplayObject ;

	doubleClickTime = 0;

	static doubleClickEvent = 'ENV_MAINWINDOW_DOUBLECLICK';

	private onTouchBeginMain(e: egret.TouchEvent): void {
		const { target } = e;
		if (this.doubleClick === target && new Date().getTime() - this.doubleClickTime < 300) {
			this.doubleClick = null;
			target.dispatchEventWith(MainDoubleClick.doubleClickEvent, false,
				{ x: Math.floor(e.localX), y: Math.floor(e.localY) });
		} else {
			this.doubleClick = target;
			this.doubleClickTime = new Date().getTime();
		}
	}
}
